package com.jlu.yygh.controller;

import com.jlu.yygh.common.result.Result;
import com.jlu.yygh.model.user.Admin;
import com.jlu.yygh.service.AdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "登录管理")
@RestController
@RequestMapping("/admin/admin/user")
public class LoginController {

  @Autowired
  private AdminService adminService;

  @PutMapping("/login/{username}/{password}")
  @ApiOperation(value = "登录接口")
  public Result login(@PathVariable String username, @PathVariable String password){
    System.out.println(username + "admin");
    System.out.println(password + "password");
    Admin admin = adminService.getAdmin(username);
    System.out.println(admin);
    if (admin == null){
     return Result.fail();
    }
    System.out.println(admin.getName());
    System.out.println(admin.getPassword());
    return Result.ok(admin);
  }
}
